-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/paymaster foundry tests #1
Conversation
ShivaanshK
commented
Jul 1, 2024
- Unit tests for BiconomySponsorshipPaymasterWithPremium
- Fuzz tests for BiconomySponsorshipPaymasterWithPremium
Fix/project build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To enhance the readability and cleanliness of your code I think you should try breaking up large blocks with new lines where appropriate. This makes the code easier to read and understand
test/foundry/base/NexusTestBase.sol
Outdated
vm.prank(FACTORY_OWNER.addr); | ||
META_FACTORY.addFactoryToWhitelist(address(FACTORY)); | ||
HANDLER_MODULE = new MockHandler(); | ||
// EXECUTOR_MODULE = new MockExecutor(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove commented code
test/foundry/base/NexusTestBase.sol
Outdated
NexusAccountFactory internal FACTORY; | ||
BiconomyMetaFactory internal META_FACTORY; | ||
MockHandler internal HANDLER_MODULE; | ||
// MockExecutor internal EXECUTOR_MODULE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove commented code
test/foundry/base/NexusTestBase.sol
Outdated
event OwnershipTransferred(address indexed oldOwner, address indexed newOwner); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this to EventsAndErrors
test/foundry/base/NexusTestBase.sol
Outdated
import { BiconomyMetaFactory } from "nexus/contracts/factory/BiconomyMetaFactory.sol"; | ||
import { MockValidator } from "nexus/contracts/mocks/MockValidator.sol"; | ||
import { MockHook } from "nexus/contracts/mocks/MockHook.sol"; | ||
// import { MockExecutor } from "nexus/contracts/mocks/MockExecutor.sol"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this
function test_SetVerifyingSigner() external { | ||
vm.startPrank(PAYMASTER_OWNER.addr); | ||
vm.expectEmit(true, true, true, true, address(bicoPaymaster)); | ||
emit IBiconomySponsorshipPaymaster.VerifyingSignerChanged( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@livingrockrises we should change the name of the methods / funcs that contains verifying
as it is the old name and we changed it since then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is still verifyingSigner!
paymaster name change to sponsorship paymaster is good
but what do you suggest then for this verifyingSigner?
} | ||
|
||
function test_RevertIf_UnauthorizedSetVerifyingSigner() external { | ||
vm.startPrank(DAN_ADDRESS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prank here is not really necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can call it directly imo
function test_SetFeeCollector() external { | ||
vm.startPrank(PAYMASTER_OWNER.addr); | ||
vm.expectEmit(true, true, true, true, address(bicoPaymaster)); | ||
emit IBiconomySponsorshipPaymaster.FeeCollectorChanged( | ||
PAYMASTER_FEE_COLLECTOR.addr, DAN_ADDRESS, PAYMASTER_OWNER.addr | ||
); | ||
bicoPaymaster.setFeeCollector(DAN_ADDRESS); | ||
assertEq(bicoPaymaster.feeCollector(), DAN_ADDRESS); | ||
vm.stopPrank(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check initial state
function test_RevertIf_SetFeeCollectorToZeroAddress() external { | ||
vm.startPrank(PAYMASTER_OWNER.addr); | ||
vm.expectRevert(abi.encodeWithSignature("FeeCollectorCannotBeZero()")); | ||
bicoPaymaster.setFeeCollector(address(0)); | ||
vm.stopPrank(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
function test_RevertIf_UnauthorizedSetFeeCollector() external { | ||
vm.startPrank(DAN_ADDRESS); | ||
vm.expectRevert(abi.encodeWithSignature("Unauthorized()")); | ||
bicoPaymaster.setFeeCollector(DAN_ADDRESS); | ||
vm.stopPrank(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same applies for all Unauthorized errors
there are errors on checks, please fix compiler issues and test issues |
since you removed |
31a4ea1
to
81abba5
Compare
…my/gasdaddy into feat/paymaster-foundry-tests
Can you also add a test for parsePaymasterAndData |
assertEq(address(testArtifact.entryPoint()), ENTRYPOINT_ADDRESS); | ||
assertEq(testArtifact.verifyingSigner(), PAYMASTER_SIGNER.addr); | ||
assertEq(testArtifact.feeCollector(), PAYMASTER_FEE_COLLECTOR.addr); | ||
assertEq(testArtifact.postOpCost(), 0 wei); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's set some postOpCost upon deployment..
bicoPaymaster.setPostopCost(newPostopCost); | ||
} | ||
|
||
function test_DepositFor() external { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just remembered depositFor when you do first time it will be cold access on paymasterIdBalances
and second time it will be warm.
so with different dapp accounts tests should keep this in mind. accounting wise too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review i
looks good.
on naming convention of some methods may have some inputs in a bit
check failing CI flows as well, take help of Adam later |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM